package com.tank.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ItemUtil {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String str="@zhuo_yr hello @helleeeeeeo @test  ";
		
		Pattern pat=Pattern.compile("@(\\w{6,20})\\s");
		Matcher mat=pat.matcher(str);
		StringBuilder sb=new StringBuilder();
		List<String> ls=new ArrayList<String>();
		while(mat.find()){
			System.out.println(mat.group());
			System.out.println(mat.group(1));
			sb.append("'"+mat.group(1)+"',");
			ls.add(mat.group(1));
		}
		
//		System.out.println(sb.length());	
//		
//		if(sb.length()>0){
//			
//			sb.append("'aaa'");
//			System.out.println(sb.toString());
//			
//		}
		
		int i=ls.size();
		
		while(i-->0){
			str=str.replace("@"+ls.get(i), "["+i+","+ls.get(i)+"]");
		}
		
		
		System.out.println("ggg:"+str.replaceAll("\\[(\\d+),(\\w+)\\]","< id='$1',$2>"));
		
		
		System.out.println(str);

	}


}
